'''
“任我学”学生幼儿综合意外保险
'''
import sys

sys.path.append('../')
from common.config import *
from db.mysql import MysqlClient
from itertools import product
from common.helper import Helper
from urllib.parse import urlencode
import requests
import json


class Spider(object):
    def __init__(self):
        self.mysql = MysqlClient()
        self.name = "“任我学”学生幼儿综合意外保险"

    # 生成产品数据
    def genProductInfo(self):
        plan = {

            "planA":{
                "意外伤害":"2w",
                "住院医疗":"2w",
                "门诊医疗":"2k",
                "疾病身故、残疾":"2w"
            },
            "planB": {
                "意外伤害": "4w",
                "住院医疗": "4w",
                "门诊医疗": "4k",
                "疾病身故、残疾": "4w",
                "重大疾病":"0"
            },
            "planC": {
                "意外伤害": "10w",
                "住院医疗": "10w",
                "门诊医疗": "1w",
                "疾病身故、残疾": "0",
                "重大疾病": "100元/日"
            },

        }

        prices =["60","100","200"]

        expire = "3-30岁学生或者幼儿"

        for k,v in zip(plan.values(),prices):

            expire = 1

            k = "'" + json.dumps( k ,ensure_ascii=False) + "'"

            print(  'INSERT INTO `“任我学”学生幼儿综合意外保险`(`plan`,`expire`,`price`)VALUES({0},"{1}","{2}")'.format(k,str(expire),v ))

            # 写入数据库
            self.mysql.cursor.execute('INSERT INTO `“任我学”学生幼儿综合意外保险`(`plan`,`expire`,`price`)VALUES({0},"{1}","{2}")'.format(

                k,str(expire),v


                ))

            self.mysql._conn.commit()




if __name__ == '__main__':
    s = Spider()

    s.genProductInfo()
